﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SGArchiveSystem7x.Controllers.Statistics
{
    public class StatBrrController : BaseController
    {
        string sControllerName = "StatBrr";
        // GET: StatBrr
        public ActionResult Index()
        {
            var n = this.VaildUser(sControllerName);
            if (n != null)
                return n;

            ///清除Page级的Session
            App_Code.CSession.Clear_PageSession(Session);

            return View();
        }
        
        public ActionResult ViewTongji(string sd, string ed)
        {
            var n = this.VaildUser(sControllerName);
            if (n != null)
                return n;

            if (sd != null && sd != "")
                sd = sd + " 00:00:01";
            if (ed != null && ed != "")
                ed = ed + " 23:59:59";
            ViewBag.SD = sd;
            ViewBag.ED = ed;
            return View();
        }

        /// <summary>
        /// 电子件与实体借阅的分类
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Get_ajaxTongji_Type(string sd, string ed)
        {
            int year = DateTime.Now.Year;
            var list = SGArchiveSystem7xDB.Sql.SGTongji.Tongji_BrrType(sd, ed);
            if (list == null)
                list = new List<SGArchiveSystem7xDB.Sql.TongjiEn>();
            return Json(list.ToArray(), JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 借阅的档案类型
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Get_ajaxTongji_ArType(string sd, string ed)
        {
            int year = DateTime.Now.Year;
            var list = SGArchiveSystem7xDB.Sql.SGTongji.Tongji_BrrAtype(sd, ed);
            if (list == null)
                list = new List<SGArchiveSystem7xDB.Sql.TongjiEn>();
            return Json(list.ToArray(), JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 利用目的的分类
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Get_ajaxTongji_Lymd(string sd, string ed)
        {
            int year = DateTime.Now.Year;
            var list = SGArchiveSystem7xDB.Sql.SGTongji.Tongji_BrrLymd(sd, ed);
            if (list == null)
                list = new List<SGArchiveSystem7xDB.Sql.TongjiEn>();
            return Json(list.ToArray(), JsonRequestBehavior.AllowGet);
        }
    }
}